import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2024-11-06
 * Time: 21:25
 */
public class test2 {
    /*
    NewCorder DP34 模板前缀和
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 前缀和问题
        // 数据的读入
        int n = in.nextInt(),q = in.nextInt();
        int [] arr = new int [n+1];
        for(int i=1;i<=n;i++){
            arr[i]=in.nextInt();
        }
        // 2.预处理一个前缀和数组
        long[] dp = new long[n+1];  //long为了防止溢出
        for(int i =1;i<=n;i++){
            dp[i]=dp[i-1]+arr[i];
        }
        while(q>0){
            int l =in.nextInt();
            int r =in.nextInt();
            System.out.println(dp[r]-dp[l-1]);
            q--;
        }
    }
}
